﻿<StackPanel 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:local="clr-namespace:SilverlightBusinessApplication.Controls"
    xmlns:login="clr-namespace:SilverlightBusinessApplication.LoginUI"
    x:Class="SilverlightBusinessApplication.LoginUI.LoginForm"
    KeyDown="LoginForm_KeyDown"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance Type=login:LoginInfo}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <local:BusyIndicator x:Name="busyIndicator" BusyContent="{Binding Path=Strings.BusyIndicatorLoggingIn, Source={StaticResource ApplicationResources}}"
                             IsBusy="{Binding IsLoggingIn}">
            <StackPanel Orientation="Vertical">
                <toolkit:DataForm x:Name="loginForm"
                                  Padding="10,0,10,0"
                                  CurrentItem="{Binding}"
                                  IsEnabled="{Binding IsLoggingIn, Converter={StaticResource NotOperatorValueConverter}}"
                                  AutoEdit="True" CommandButtonsVisibility="None" HeaderVisibility="Collapsed" 
                                  AutoGeneratingField="LoginForm_AutoGeneratingField" 
                                  Style="{StaticResource LoginDataFormStyle}" />
            </StackPanel>
        </local:BusyIndicator>

        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
            <Button x:Name="loginButton" Content="{Binding Path=Strings.OKButton, Source={StaticResource ApplicationResources}}" Click="LoginButton_Click" Style="{StaticResource RegisterLoginButtonStyle}" IsEnabled="{Binding Path=CanLogIn}" />
            <Button x:Name="loginCancel" Content="{Binding Path=Strings.CancelButton, Source={StaticResource ApplicationResources}}" Click="CancelButton_Click" Style="{StaticResource RegisterLoginButtonStyle}" />
        </StackPanel>

        <StackPanel Grid.Row="1" Grid.Column="0" Style="{StaticResource RegisterLoginLinkPanelStyle}">
            <TextBlock Text="{Binding Path=Strings.NotRegisteredYetLabel, Source={StaticResource ApplicationResources}}" Style="{StaticResource CommentStyle}"/>
            <HyperlinkButton x:Name="registerNow" Content="{Binding Path=Strings.RegisterNowButton, Source={StaticResource ApplicationResources}}" Click="RegisterNow_Click" IsEnabled="{Binding IsLoggingIn, Converter={StaticResource NotOperatorValueConverter}}" />
        </StackPanel>
    </Grid>
</StackPanel>